# 从视频中均匀抽取帧保存为jpg
# 在图片路径打开终端

import os

def get_all_mp4_names(folder_path):
    mp4_names = []
    for root, dirs, files in os.walk(folder_path):
        for file in files:
            if file.endswith(".mp4"):
                mp4_names.append(file[:-4])
    return mp4_names

# 自定义图片路径
folder_path = "path/to/mp4/folder"

mp4_names = get_all_mp4_names(folder_path+"/mp4")

for mp4_name in mp4_names:
    # -r * 每秒抽*帧
    os.system('ffmpeg -i {}/mp4/{}.mp4 -r 2 -f image2 {}-%05d.jpg'.format(folder_path, mp4_name, mp4_name))

